      <div class="templatemo-content-wrapper">
        <div class="templatemo-content">
          <ol class="breadcrumb">
            <li><a href="<?=site_url()?>/product/index">商品管理</a></li>
            <li class="active">进货价变化</li>
          </ol>
           <div class="row margin-bottom-5">
             <div class="col-md-12">
             	<input type="text" id="key" placeholder="输入商品名称" value="<?php echo $product['name']; ?>">
             	<input type="hidden" name="productid" id="productid" value="<?php echo $product['id']; ?>"> 
 				<input type="hidden" name="unit" id="unit" value="<?php echo $product['unit']; ?>">
            	开始日期
            	<input type="text" id="startdate" name="startdate" value="<?php echo date('Y-m-d',strtotime('-2 month')); ?>">
            	结束日期
            	<input type="text" id="enddate" name="enddate" value="<?php echo date('Y-m-d',time()); ?>">
            	<button class="btn btn-primary" id="submit_btn">搜索</button>
            </div>
           </div>
           <hr />
           <div id="data" style="min-width:800px;height:400px">										 		
		   </div> 
        </div>
      </div>
    <script>
	$(document).ready(function() {
		$('#startdate').datepicker({
			dateFormat: 'yy-mm-dd',
			monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
			dayNamesMin: ['日','一','二','三','四','五','六']
		});
		$('#enddate').datepicker({
			dateFormat: 'yy-mm-dd',
			monthNames: ['一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月'],
			dayNamesMin: ['日','一','二','三','四','五','六']
		});
		$("#submit_btn").click(function(){
     		GetseriesValue(); 
    	 });
    	 $("#submit_btn").click();
	}); 
function GetseriesValue() {
 	var productid = $("#productid").val(); 
 	var unit = $("#unit").val(); 
    var startdate = $("#startdate").val(); 
 	var enddate = $("#enddate").val(); 
    $.ajax({
    	url : '<?php echo site_url('product/getPricechanges')?>',
        type: "post",
        data: {
        	 productid: productid, 
        	 startdate: startdate, 
        	 enddate: enddate
         },
        dataType: "json",
        success: function (result) {
       		dataX=result.dates;
       		dataP=result.prices;
       		GetData(dataX,dataP,unit);
        }
    });
};

function GetData(dataX,dataP,unit) {
     $('#data').highcharts({
        title: {
            text: '商品进货价变化表',
            x: -20 //center
        },
        xAxis: {
            categories: dataX
        },
        yAxis: {
            title: {
                text: '单位：元/'+unit
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            valueSuffix: '元/'+unit
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
        series: [{ 
        	name:"价格",
        	data: dataP
        }],
        credits: {  
            enabled: false,
        }  
    });
}
</script>